# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=py3-lxml
_pkgname=lxml
pkgver=5.3.0
pkgrel=0
pkgdesc="Python3 LXML Library"
url="https://lxml.de/"
arch="all"
license="BSD-3-Clause AND ZPL-2.0 AND ElementTree"
makedepends="
	cython
	libxml2-dev
	libxslt-dev
	py3-gpep517
	py3-setuptools
	py3-wheel
	python3-dev
	"
checkdepends="py3-html5lib"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz
	libxml-2.11.0.patch
	tests-fix-encoding-name.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"

# secfixes:
#   4.9.2-r0:
#     - CVE-2022-2309
#   4.6.5-r0:
#     - CVE-2021-43818
#   4.6.2-r0:
#     - CVE-2020-27783
#   4.6.3-r0:
#     - CVE-2021-28957

build() {
	export CFLAGS="$CFLAGS -flto=auto"
	gpep517 build-wheel \
		--wheel-dir .dist \
		--config-json '{"--build-option": ["--with-cython"]}' \
		--output-fd 3 3>&1 >&2
}

check() {
	local testpy3="$builddir"/.testenv/bin/python3
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	make PYTHON="$testpy3" PYTHON3="$testpy3" test
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
7f8a3717645893bc6f790cc9adfb8fdab91c352dc4dc23c0ccb4af9a0d138acf9ef5054e9786af497955f10079e9242dbd63ea9ac39c33bfd71ca2fe4ef4a7c0  lxml-5.3.0.tar.gz
6436f87042563bb3a08bd7d0216fdb284d639b1a72fde77dce75d7c3e63f4f18ba115df9540fe4298f558df53f9dbfbd781374138544e8e5d9cb5ca5928f343c  libxml-2.11.0.patch
9adaadb7f082557555f9db5f923bb764f0c9d255a9010c0f1b5f5c67690e373b62e0f8418c37ccf13cf23f2f609623516ee87dc73602dea30d5547b6cd60f55e  tests-fix-encoding-name.patch
"
